using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Xoohoo.Repositories.SqlServerEF.Entities;

namespace Xoohoo.Repositories.SqlServerEF.Mapping
{
	public class BulletinMap : EntityTypeConfiguration<Bulletin>
	{
		public BulletinMap()
		{
			// Primary Key
			this.HasKey(t => t.BulletinID);

			// Properties
			this.Property(t => t.Title)
				.HasMaxLength(200);
				
			this.Property(t => t.Content)
				.IsRequired()
				.HasMaxLength(2000);
				
			// Table & Column Mappings
			this.ToTable("Bulletin");
			this.Property(t => t.BulletinID).HasColumnName("BulletinID");
			this.Property(t => t.IsShow).HasColumnName("IsShow");
			this.Property(t => t.Title).HasColumnName("Title");
			this.Property(t => t.Content).HasColumnName("Content");
			this.Property(t => t.PublishDate).HasColumnName("PublishDate");
		}
	}
}

